

package com.hazelcast.partition;

import com.hazelcast.cluster.Member;

import javax.annotation.Nullable;

/**
 * In Hazelcast the data is split up in partitions: by default, 271 and configurable through the 'hazelcast.partition.count'
 * ClusterProperty. Each partition is owned by one member and the ownership can change if members join or leave the cluster.
 * <p>
 * Using this Partition object, you get access to who is the owner of a given partition. This object is not a DTO, so it will
 * be updated when a member changes ownership.
 */
public interface Partition {

    /**
     * Returns the ID of the partition. This value will never change and will always be greater to or equal to 0 and smaller
     * than the partition-count.
     *
     * @return the ID of the partition
     */
    int getPartitionId();

    /**
     * Returns the current member that owns this partition.
     * <p>
     * The returned value could be stale as soon as it is returned.
     * <p>
     * It can be that null is returned if the owner of a partition has not been established.
     *
     * @return the owner member of the partition
     */
    @Nullable
    Member getOwner();
}
